package com.java.test.user.onlinemembermanagepush;

import com.java.test.controller.BaseController;
import com.java.test.dto.ResponseDTO;
import com.java.test.system.dto.LoginAccountInfo;
import com.java.test.user.onlinemembermanagepush.dto.OffLineMemberDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * 在线会员Controller
 *
 * @author lijie1
 * @date 2020/7/9 0009
 */
@Slf4j
@RestController
@RequestMapping("/memberPush")
public class OnLineMemberManageController extends BaseController {

    OnLineMemberManageService onLineMemberManageService;
    @Autowired
    public void setOnLineMemberManageService(OnLineMemberManageService onLineMemberManageService) {
        this.onLineMemberManageService = onLineMemberManageService;
    }

    @RequestMapping(value = "/offLineMember",method = RequestMethod.POST)
    public ResponseDTO<String> offLineMember(@RequestBody @Valid OffLineMemberDTO dto, HttpServletRequest request) {
        log.debug("----------会员下线----------");
        LoginAccountInfo user = (LoginAccountInfo) request.getSession().getAttribute("user");
        systemManageService.insertlogInfo(user.getLoginAccout(), user.getIp(), "会员管理-在线会员-会员下线"+dto.getId());
        return onLineMemberManageService.offLineMember(dto);
    }
}
